<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body style="height: 5000px;">
    <script>
      function debounce(method, delay) {
        let timer = null
        return function() {
          // console.log(arguments)
          let self = this,
            args = arguments
          timer && clearTimeout(timer)
          timer = setTimeout(function() {
            // method.apply(self, args)
            method.apply(null,args)
          }, delay)
        }
      }
      window.onscroll = debounce(function(e) {
        console.log(e)
        let scrollTop =
          document.body.scrollTop || document.documentElement.scrollTop
        console.log('滚动条位置：' + scrollTop)
      }, 200)
    </script>
  </body>
</html>
